#include "mystdio.h"
#include <stdlib.h>

#define LOG "log.txt"

int main()
{
  My_FILE* fp = myfopen(LOG, "w");
  if(fp == NULL)
  {
    perror("myfopen\n");
    exit(-1);
  }
 
  char buffer[32];
  int cnt = 5;

  while(cnt)
  {
    snprintf(buffer, sizeof(buffer), "hello world %d\n", cnt);
    myfwrite(buffer, strlen(buffer), 1, fp);
    cnt--;
  }

  myfclose(fp);

  return 0;
}
